﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Imaging;

namespace KGE.Define
{
    [Serializable]
    public class KImagePackage
    {
        public string Name;
        public Guid GUID;
        public string Version;
        public DateTime CreateTime;

        List<KImage> items = new List<KImage>();
        public KImage this[int i]
        {
            get
            {
                if (i < 0)
                {
                    return null;
                }
                return items[i];
            }
        }
        public KImage this[string name]
        {
            get
            {
                return this[GetIndex(name)];
            }
        }
        public int GetIndex(string name)
        {
            for (int i = 0; i < items.Count; i++)
            {
                if (items[i].Name == name)
                {
                    return i;
                }
            }
            return -1;
        }
        public int Count
        {
            get
            {
                return items.Count;
            }
        }
        public void Add(KImage ki)
        {
            items.Add(ki);
        }
        public KImagePackage()
        {
            GUID = Guid.NewGuid();
            CreateTime = DateTime.Now;
        }
        //public KImagePackage(Image gif)
        //{
        //    FrameDimension fd = new FrameDimension(gif.FrameDimensionsList[0]);
        //    int c = gif.GetFrameCount(fd);
        //    //items = new KImage();

        //    for (int i = 0; i < c; i++)
        //    {
        //        gif.SelectActiveFrame(fd, i);
        //        items.Add(new KImage(new Bitmap(gif)));
        //    }
        //}
    }
}
